using System;
using System.Collections.Generic;
using System.Text;
using GeneratorLibrary.Client.Base;
using System.Data;

namespace GeneratorLibrary.Client.SqlClient {
    public class SqlCrudColumn : CrudColumnBase {
        public SqlCrudColumn(DataRow row) : base(row) { }

        public override string GetDefaultCoalesce() {
            switch (DataType.ToLower()) {
                case "bigint":
                case "decimal":
                case "money":
                case "smallmoney":
                case "float":
                case "int":
                case "real":
                case "smallint":
                case "numeric":
                case "tinyint":
                    return "0";
                case "bit":
                    return "2";
                case "datetime":
                case "smalldatetime":
                case "date":
                case "time":
                case "datetime2":
                case "datetimeoffset":
                    return "getdate()";
                default:
                    return "''";
            }
            return null;
        }

        protected override string getQualifiedDataType() {
            switch (this.DataType.ToLower()) {
                case "decimal":
                case "numeric":
                    return this.DataType + "(" + this.NumericPrecision.ToString() + "," + this.NumericScale.ToString() + ")";
                case "nchar":
                case "nvarchar":
                case "char":
                case "varchar":
                    return this.DataType + "(" + this.CharMaxLength.ToString() + ")";
                case "binary":
                case "varbinary":
                    return this.DataType + "(" + this.Length.ToString() + ")";
                default:
                    return this.DataType;
            }
        }
    }
}
